//
// Created by yangchao on 2022/4/22.
// 11. 盛最多水的容器: https://leetcode-cn.com/problems/container-with-most-water/
//
#include <vector>
using namespace std;

//双指针
class MaxArea {
public:
    int maxArea(vector<int>& height) {
        int left = 0, right = height.size()-1;
        int res = 0;
        while (left < right) { //(right-left)和height[left++]的顺序不能调换
            res = height[left] < height[right] ?
                  max(res,(right-left)*height[left++]):
                  max(res,(right-left)*height[right--]);
        }
        return res;
    }
};

